using System;
using System.IO;
using System.Xml.Serialization;

namespace SoftwareMonkeys.Scriptech.Projects
{
	public class ProjectReader
	{
		
		public static Project GetProject(string storeName, string groupName, string projectName)
		{
			string projectPropertiesPath = ProjectFileNamer.GetProjectPropertiesPath(storeName, groupName, projectName);
			
			Project project = LoadProjectFromFile(projectPropertiesPath);
			
			return project;
		}
		
		public static Project LoadProjectFromFile(string filePath)
		{
			Project project = null;
			
			using (StreamReader reader = new StreamReader (File.OpenRead (filePath))) {
				XmlSerializer serializer = new XmlSerializer (typeof(Project));
				project = (Project)serializer.Deserialize (reader);
			}
			
			return project;
		}
	}
}

